//自己实现，二分法
class Solution {
public:
    vector<int> searchRange(vector<int>& nums, int target) {
        int sz=nums.size();
        vector<int>ans;
        int left=0,right=sz-1,mid=0,cur=0;
        while(left<=right)
        {
            mid=left+(right-left)/2;
            if(nums[mid]>target) right=mid-1;
            else if(nums[mid]<target) left=mid+1;
            else
            {
                cur=mid;
                while(mid-1>=0&&nums[mid-1]==target){--mid;}
                ans.push_back(mid);
                while(cur+1<sz&&nums[cur+1]==target){++cur;}
                ans.push_back(cur);
                return ans;
            }
        }
        return {-1,-1};
    }
};
